package com.chatplus.application.domain.response;

import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.util.Objects;

/**
 * 验证码校验返回响应
 *
 * @author weird
 */
public class CaptchaResponse implements Serializable {
    private final static long serialVersionUID = 2382424829341950882L;

    @ApiModelProperty("验证结果: 100 验证成功, 900 验证失败")
    private String code;

    @ApiModelProperty("调用状态: true 表示调用成功,false 表示调用失败")
    private boolean success;

    @ApiModelProperty("返回的结果数据")
    private String data;

    public CaptchaResponse(String code, boolean success, String data) {
        this.code = code;
        this.success = success;
        this.data = data;
    }

    public static CaptchaResponse ofError() {
        return new CaptchaResponse("900", false, "");
    }

    public static CaptchaResponse ofSuccess() {
        return new CaptchaResponse("100", true, "");
    }

    public static CaptchaResponse ofFail() {
        return new CaptchaResponse("900", true, "");
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public boolean isSuccess() {
        return success;
    }

    public boolean isPass() {
        return Objects.equals(getCode(), "100");
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getData() {
        return data;
    }

    public void setData(String data) {
        this.data = data;
    }
}
